﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq.Expressions;
using System.Reflection.Metadata;
using System.Threading.Tasks;

namespace KingerRobot.PCRBW.SpiService;

public interface IWcsTaskRepository
{
    #region 同步查询
    /// <summary>
    /// 根据Id查询实体
    /// </summary>
    /// <param name="objId"></param>
    /// <returns></returns>
    POWcsTask QueryById(long objId);
    /// <summary>
    /// 根据id数组查询实体list
    /// </summary>
    /// <param name="lstIds"></param>
    /// <returns></returns>
   List<POWcsTask> QueryByIDs(object[] lstIds);

    /// <summary>
    /// 添加
    /// </summary>
    /// <param name="model"></param>
    /// <returns></returns>
   int Add(POWcsTask model);

    /// <summary>
    /// 批量添加
    /// </summary>
    /// <param name="listEntity"></param>
    /// <returns></returns>
   int Add(IEnumerable<POWcsTask> listEntity);

    /// <summary>
    /// 根据id 删除某一实体
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
   int DeleteById(long id);


    /// <summary>
    /// 根据id数组，删除实体list
    /// </summary>
    /// <param name="ids"></param>
    /// <returns></returns>
    int Deletes(IEnumerable<POWcsTask> entitys);

    /// <summary>
    /// 更新model
    /// </summary>
    /// <param name="model"></param>
    /// <returns></returns>
    int Update(POWcsTask model);

    /// <summary>
    /// 根据model，更新，带where条件
    /// </summary>
    /// <param name="entity"></param>
    /// <param name="strWhere"></param>
    /// <returns></returns>
    int Update(Expression<Func<POWcsTask, bool>> whereExpression, POWcsTask entity);

    /// <summary>
    /// 正序查询第一条数据
    /// </summary>
    /// <returns></returns>
    POWcsTask First();
    /// <summary>
    /// 根据条件查询查询第一条数据
    /// </summary>
    /// <param name="whereExpression"></param>
    /// <returns></returns>
   POWcsTask First(Expression<Func<POWcsTask, bool>> whereExpression);

    /// <summary>
    /// 查询
    /// </summary>
    /// <returns></returns>
   List<POWcsTask> Query();


    /// <summary>
    /// 根据表达式查询
    /// </summary>
    /// <param name="whereExpression"></param>
    /// <returns></returns>
   List<POWcsTask> Query(Expression<Func<POWcsTask, bool>> whereExpression);
    /// <summary>
    /// 根据sql语句查询
    /// </summary>
    /// <param name="strSql">完整的sql语句</param>
    /// <param name="parameters">参数</param>
    /// <returns>泛型集合</returns>
    List<POWcsTask> QuerySql(string strSql, Parameter[] parameters = null);
    /// <summary>
    /// 根据sql语句查询 执行update、delete、add
    /// </summary>
    /// <param name="strSql">完整的sql语句</param>
    /// <param name="parameters">参数</param>
    /// <returns>泛型集合</returns>
    int ExecuteSqlRaw(string strSql, Parameter[] parameters);

    #endregion


    #region 执行事务
    /// <summary>
    /// 执行创建事务
    /// </summary>
    /// <param name="wcsTask"></param>
    /// <param name="wcsTaskCmd"></param>
    /// <returns></returns>
    int ExecAddTran(POWcsTask wcsTask, POWcsTaskCmd wcsTaskCmd);
    /// <summary>
    /// 创建入库任务
    /// </summary>
    /// <param name="wcsTask"></param>
    /// <param name="wcsTaskCmd"></param>
    /// <returns></returns>
    int ExecAddWarehouseingTaskTran(POWcsTask wcsTask, POWcsTaskCmd wcsTaskCmd);
    /// <summary>
    /// 执行更新事务
    /// </summary>
    /// <param name="wcsTask"></param>
    /// <param name="wcsTaskCmd"></param>
    /// <returns></returns>
    int ExecUpdateTran(POWcsTask wcsTask, POWcsTaskCmd wcsTaskCmd);
    /// <summary>
    /// 执行删除事务
    /// </summary>
    /// <param name="wcsTask"></param>
    /// <param name="wcsTaskCmd"></param>
    /// <returns></returns>

    int ExecDelTran(POWcsTask wcsTask, POWcsTaskCmd wcsTaskCmd);
    #endregion

    /// <summary>
    /// 更新状态
    /// </summary>
    /// <param name="wcsTask"></param>
    /// <param name="wcsTaskCmd"></param>
    /// <returns></returns>
    int ExecUpdateByTaskStatusTran(POWcsTask wcsTask, POWcsTaskCmd wcsTaskCmd, int status);
    /// <summary>
    /// 创建任务和指令
    /// </summary>
    /// <param name="taskDTO"></param>
    /// <returns></returns>
    TaskInfoBean CreateTaskAndCmd(TaskDTO taskDTO);
    /// <summary>
    /// 获取所有任务
    /// </summary>
    /// <param name="equipId"></param>
    /// <returns></returns>
    List<TaskCmdAndLocDto> GetTaskAndCmdBeanByCmdEquipId(long equipId);

    /// <summary>
    /// 备份并删除任务
    /// </summary>
    /// <param name="wcsTask"></param>
    /// <returns></returns>
    int BakAndDeleteData(POWcsTask wcsTask);
    /// <summary>
    /// 桁架任务
    /// </summary>
    /// <param name="equipId"></param>
    /// <returns></returns>
    List<TaskCmdAndLocDto> GetTrussTaskAndCmdBeanByCmdEquipId(long equipId);
    /// <summary>
    /// 获取清理任务
    /// </summary>
    /// <returns></returns>
    TaskAndCmdBean QueryClearTask();
    /// <summary>
    /// 删除任务
    /// </summary>
    /// <param name="taskCmd"></param>
    /// <returns></returns>

    int DelTaskAndCmd(TaskAndCmdBean taskCmd);
}
